function ex_InvPendulum
m=1;
M=2;
d=0;
L=5;
g=9.8;
A=[
0   1   0   0
0   0   -m/M*g  0
0   0   0   1
0   0   (M+m)/(M*L)*g   0
];
B_u=[
0
1/M
0
-1/(M*L)
];
B_d=[
0
-1/M
0
(M+m)/(m*M*L)
];
Q=diag([1,1,10,10]);
R=[1];
K=lqr(A,B_u,Q,R);

P1=newplayer(...
'Vars',[0,0,2,0],...
'draw_player_trace_func',[],...
'draw_player_func','IP_draw_player',...
'ode_func',@IP_ode_func,...
'calc_pos_ang_func','IP_pos_ang',...
'step_func','IP_step_player',...
'L',L,...
'A',A,...
'B_u',B_u,...
'B_d',B_d,...
'Q',Q,...
'R',R,...
'K',K...
)

G=newgame({P1},...
'h',0.01,...
'max_time',20,...
'axis',[0,20,-10,10],...
'pause','pause(G.h);',...
'draw_game_trace_func',[],...
'draw_game_board_func','IP_draw_board'...
)
G=simgame(G)


